/**
 * Author: runlin.tang
 * Creation Time: 2016-06-29.
 * Description:.���WAN口的PPPOE连接方式接口
 */
define(['jquery','../../common/ajax/ajax'],
    function($,ajax) {
        function example(wan_pppoe_user,wan_pppoe_password){
            ajax({
                url:interfaces.set_wan_pppoe_settings.url,
                dataType:interfaces.set_wan_pppoe_settings.dataType,
                type:interfaces.set_wan_pppoe_settings.type,
                data:JSON.stringify({
                    pppname:wan_pppoe_user,
                    password:wan_pppoe_password
                }),
                cache:{
                    use:false,
                    name:'',
                    time:10
                },
                isOk:function(data){
                    var datas = '';
                    if(useNetData){
                        datas = data;
                    }else{
                        datas = data.pppoelinks;
                    }
                    if(datas.data.wan_set_status == 0){
                        var links  = '<div class="contect-state"><i>联网状态</i><span>已连接</span></div>';
                        $(".ly-pppoe").before(successLink);
                        $(".ly-tip").remove();
                        $(".com_btn").remove();
                         var successLink = '<div class="ly-tip ok-tip"><i></i><span>网络连接成功，请点击下一步！</span></div><div class="com_btn"><a href="javascript:;" class="com_btn_next">下一步</a></div>';
                        $(".ly-pppoe").after(successLink);
                    }else{
                        var error_msg = '';
                        if(datas.data.wan_pppoe_errormsg == 0){
                            error_msg = 'PPPOE服务器没有响应';
                        }else if(datas.data.wan_pppoe_errormsg == 1){
                            error_msg = 'PPPOE连接超时';
                        }else if(datas.data.wan_pppoe_errormsg == 2){
                            error_msg = '用户名或密码错误';
                        }else if(datas.data.wan_pppoe_errormsg == 3){
                            error_msg = '没有发现PPPOE服务器';
                        }else if(datas.data.wan_pppoe_errormsg == 4){
                            error_msg = 'PPPOE无法连接外网';
                        }

                        $(".ly-tip span").html(error_msg);
                    }


                }
            });
        }
        return example;
    });
